package patrol.mobile.com.mobilepatrol.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.bean.NewsListBean;

/**
 * Created by K on 2018/9/11.
 * des: 新闻列表
 */
public class NewsListAdapter extends BaseQuickAdapter<NewsListBean> {
    String baseUrl;

    public NewsListAdapter(Context context, String baseUrl) {
        super(context);
        this.baseUrl = baseUrl;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_news_list;
    }

    @Override
    protected void convert(BaseViewHolder holder, NewsListBean item) {
        holder.setText(R.id.tv_title, item.getTitle());
        holder.setText(R.id.tv_time, item.getCreateDate());
        ImageView view = holder.getView(R.id.iv_img);
        Glide.with(mContext).load(baseUrl + item.getImage()).error(R.drawable.rc_image_error).into(view);
    }
}
